import random

import pygame

from lib.sittings import TILE_SIZE, BLOCK_COLOR, SCREENTILES


class Block(pygame.sprite.Sprite):
    def __init__(self, takenupgroup):
        pygame.sprite.Sprite.__init__(self)
        self.image = self.image = pygame.Surface(TILE_SIZE).convert()
        self.image.fill(BLOCK_COLOR)

        self.rect = self.image.get_rect()
        while True:
            self.rect.topleft = (
                random.randint(0, SCREENTILES[0]) * TILE_SIZE[0], random.randint(0, SCREENTILES[1]) * TILE_SIZE[1])
            for sprt in takenupgroup:
                if self.rect.colliderect(sprt):
                    continue  # collision, food cant go here
            break  # no collision, food can go here